package com.itheima.udp4;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

/*
发送端 客户端
 */
public class Client {
    /*
    发送多次 死循环
     */
    public static void main(String[] args) throws Exception {
        //1.创建发送对象
        DatagramSocket ds = new DatagramSocket();
        while (true) {
            //2.创建数据容器
            //组织数据
            InetAddress ip = InetAddress.getByName("255.255.255.255");
            Scanner sc = new Scanner(System.in);
            String s = sc.nextLine();
            if("886".equals(s)){
                break;
            }
            DatagramPacket dp = new DatagramPacket(s.getBytes(),s.getBytes().length,ip,8888);


            //发送
            ds.send(dp);
        }
        //释放资源
        ds.close();

    }
}
